#include <iostream>
#include <unistd.h>
#include <signal.h>
using namespace std;
void handler(int sig)
{
    cout << "收到信号" << sig << endl;
    while (true)
    {
        sigset_t s;
        sigpending(&s);
        for (int i = 31; i >= 1; i--)
        {
            if (sigismember(&s, i)) cout << '1';
            else cout << '0';
        }
        cout << endl;
        sleep(1);
    }
}
int main()
{
    struct sigaction act, oact;
    act.sa_handler = handler;
    sigemptyset(&act.sa_mask);
    sigaddset(&act.sa_mask, 2);
    sigaddset(&act.sa_mask, 3);
    sigaction(SIGINT, &act, &oact);
    while (true)
    {
        cout << "hello linux! my pid:" << getpid() << endl;
        sleep(1);
    }
    return 0;
}